home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1368 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  43 lines

  1. Newsgroups: comp.lang.c
  2. Path: gail.ripco.com!mambuhl
  3. From: mambuhl@ripco.com (Martin Ambuhl)
  4. Subject: Re: Strcat Doesn`t work  
  5. X-Nntp-Posting-Host: foley.ripco.com
  6. Message-ID: <DL3u9F.9x5@rci.ripco.com>
  7. Sender: usenet@rci.ripco.com (Net News Admin)
  8. Organization: Ripco Internet BBS Chicago
  9. Date: Sat, 13 Jan 1996 05:36:51 GMT
  10. X-Ident-Sender: mambuhl
  11.  
  12. ** Craig Cook ** <cookca@cs.purdue.edu> in
  13. <Pine.SOL.3.91.960111151925.25068C-100000@lore.cs.purdue.edu> asks:
  14.  
  15. >Here is my excerpt of code in question:
  16. >Putword(int w, char *imageChar)
  17. >{
  18. >        w = (w & 0xff);
  19. >        strcat( imageChar, (const char *)w );
  20. >}
  21. >Why does it core dump?  It should work right?
  22.  
  23. No.  Why should it work?
  24. (char *)w points to some location between 0 and 0xff.  Do you have
  25. any reason to suppose a zero-terminated character array (a string)
  26. resides there?  Hell, do you have any reason to suppose that it is even
  27. in your data region?
  28.  
  29. It is also likely that imageChar is also not a string.  You will
  30. probably find that
  31.  
  32. #define Putword(x,y) ((y << CHAR_BIT) | (x & 0xff))
  33.  
  34. or
  35.  
  36. #define Putword(x,y) ((x << CHAR_BIT) | (y & 0xff))
  37.  
  38. is closer to what you want.
  39.                                                                                                             
  40. --
  41. * Martin Ambuhl       net: mambuhl@ripco.com
  42. * Chicago, IL (USA)    
  43.